#一阶低通滤波器
class LowPassFilter:
    def __init__(self, alpha):
        self.alpha = alpha  # 滤波器的系数，0 < alpha <= 1
        self.last_output = None

    def update(self, value):
        if self.last_output is None:
            # 初始化滤波器的输出
            self.last_output = value
        else:
            # 更新滤波器的输出
            self.last_output = self.alpha * value + (1 - self.alpha) * self.last_output
        return self.last_output